import os
from http import HTTPStatus

from dashscope import Application

# 工作流和智能体编排应用自定义参数传递
biz_params = {"city": "杭州"}
response = Application.call(
    # 若没有配置环境变量，可用百炼API Key将下行替换为：api_key="sk-xxx"。但不建议在生产环境中直接将API Key硬编码到代码中，以减少API Key泄露风险。
    api_key="sk-53960037828d48d1bb40f5be4db5509a",
    app_id='9b615618ad66415c91a1ef0eb1b4aa17',  # 替换为实际的应用 ID
    prompt='根据国际海上避碰规则关于避免碰撞的行动的要求,如果本船同时与多船相遇构成碰撞危险且局面判断不清,应当_-。A.将本船当做让路船，及早采取行动 B.减速并把船停住 C.减速或把船停住 D.必要时减速或把船停住',
    biz_params={
        "skill":"analyze_question",
        "course":"二/三副船舶操纵与避碰",
        "category":"海船船员",
        "major":"驾驶",
        "position":"二副或三副"
    }  # 传递业务参数
)

if response.status_code != HTTPStatus.OK:
    print(f'request_id={response.request_id}')
    print(f'code={response.status_code}')
    print(f'message={response.message}')
    print(f'请参考文档：https://help.aliyun.com/zh/model-studio/developer-reference/error-code')
else:
    print(f'{response.output.text}')  # 处理只输出文本text